<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Performs install/uninstall methods for the Twitter Plugin
 *
 * PHP version 5
 * LICENSE: This source file is subject to AGPL license 
 * that is available through the world-wide-web at the following URI:
 * http://www.gnu.org/licenses/agpl.html
 * @author	   Omar Vega Ramos <ovruni@gnu.org.pe> 
 * @copyright      (c) 2013 - 2016 Omar Vega Ramos
 * @license	   http://www.gnu.org/licenses/agpl.html GNU Affero General Public License (AGPL) 
 */

class Twitter_Install {
  
  /**
   * Constructor to load the shared database library
   */
  public function __construct()
  {
    $this->db =  new Database();
  }
  
  /**
   * Creates the required columns for the Twitter Plugin
   */
  public function run_install()
  {
    // ****************************************
    // DATABASE STUFF
    $this->db->query("
		     CREATE TABLE IF NOT EXISTS `".Kohana::config('database.default.table_prefix')."twitter`
		     (
			id int(11) unsigned NOT NULL AUTO_INCREMENT,
			consumer_key varchar(30) DEFAULT NULL,
			consumer_secret varchar(100) DEFAULT NULL,
			oauth_token varchar(100) DEFAULT NULL,
			oauth_token_secret varchar(100) DEFAULT NULL,
			PRIMARY KEY (`id`)
		     );
		     ");
    // ****************************************
  }
  
  /**
   * Drops the Twitter Tables
   */
  public function run_uninstall()
  {
    $this->db->query("
		     DROP TABLE ".Kohana::config('database.default.table_prefix')."twitter;
		     ");
  }
}
